package cn.edu.scau.cmi.ema.service.base;

import java.beans.PropertyEditorSupport;
import java.util.HashSet;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class CmiIdsEditor extends PropertyEditorSupport{

	@Override 
	public void setAsText(String str) {
		Set<Integer> idsSet = new HashSet<>();
		String[] ids = str.split(",");
		for(int i = 0; i < ids.length; i++) {
			idsSet.add(Integer.parseInt(ids[i].trim()));
		}
		this.setValue(idsSet);
	}
	
}	
